<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul id="list">

    </ul>
    <script>
        class Person {
            constructor(name, age, location, id) {
                this.name = name
                this.age = age
                this.location = location
                this.ele = document.querySelector(`#${id}`)
            }
            get location() {
                console.log("get")
                //return this.location //死循环
            }
            set location(data) {
                console.log("set", data)
                //this.location = data //栈溢出
            }
            get html() {
                return this.ele.innerHTML
            }
            set html(data) {
                this.ele.innerHTML = data.map(item => `<li>${item}</li>`).join("")
            }
        }
        let obj = new Person("twj", 100, "长沙", "list")
        obj.html = ["111", "222", "333"]
    </script>
</body>

</html>